<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
</head>

<body>
    <script>
        /* 封装 promise */
        function get(url, data) {
            return new Promise((resolve, reject) => {
                $.ajax({
                    url: url,
                    data: data,
                    success: function (data) {
                        resolve(data);
                    },
                    error: function (err) {
                        reject(err);
                    }
                });
            })
        }

        get("mock/user.json")
            .then((data) => {
                console.log("查询用户成功", data);
                return get(`mock/user_corse_${data.id}.json`);
            })
            .then((data) => {
                console.log("查询课程成功", data);
                return get(`mock/corse_score_${data.id}.json`);
            })
            .then((data) => {
                console.log("查询分数成功", data);
            })
    </script>
</body>

</html>